/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    bool isSymmetric(TreeNode* root) {
      if(root == NULL) return true;
      return isSymmetric2(root->left, root->right);
    }

    bool isSymmetric2(TreeNode * l, TreeNode * r){
      if(l == NULL && r == NULL) return true;
      return (l -> val == r -> val) && isSymmetric2(l->left, r->right) && isSymmetric2(l->right, r->left);
    }
};
